import * as mock from 'mockjs';
import './exted.js';
var Random = mock.Random;
mock.mock('/api/ads', 'get', {
  imgUrl:
    'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F01dcde59891b2ba8012156034e9f50.gif&refer=http%3A%2F%2Fimg.zcool.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1625733179&t=3c853c54a850757cb856398bb5db9d72',
  'link|2': '123',
});
mock.mock(/\/api\/products/, 'get', {
  status: 200,
  productCount: 10,
  pageSize: 5,
  currentNum: 1,
  'data|5': [
    {
      id: 555,
      imgUrl: Random.image('160x160'),
      title: '测试5555555',
      'tags|0-3': [
        {
          text: Random.tags(),
          color: Random.color(),
        },
      ],
      price: Random.float(10, 300, 1, 2),
      order: '已拼10万+件',
      'avatar_list|1-3': [Random.avatars()],
    },
    {
      id: '@id()',
      imgUrl: Random.image('160x160'),
      title: Random.cword(10, 20),
      'tags|0-3': [
        {
          text: Random.tags(),
          color: Random.color(),
        },
      ],
      price: Random.float(10, 300, 1, 2),
      order: '已拼10万+件',
      'avatar_list|1-3': [Random.avatars()],
    },
  ],
});


/**
 * 无法使用数据模板
 * mock.mock(/\/api\/products/, 'get', (options) => {
  const url = options.url;
  const regexp = new RegExp(/\/api\/products\?pageNum=(\d+)/);
  const arr = regexp.exec(url) || [];
  const pageNum = arr[1];
  return {
    status: 200,
    productCount: 10,
    pageSize: 5,
    currentNum: 1,
    'data|5': [
      {
        id: Random.id(),
        imgUrl: Random.image('160x160'),
        title: Random.cword(10, 20),
        'tags|0-3': [
          {
            text: Random.constellation(),
            color: Random.color(),
          },
        ],
        price: Random.float(10, 300, 1, 2),
        order: '已拼10万+件',
        'avatar_list | 0-3': [Random.image('100x100')],
      },
    ],
  };
});
 */

